home *** CD-ROM | disk | FTP | other *** search
- *** 1.10 1992/03/06 19:40:24
- --- Changelo 1992/04/19 16:43:23
- ***************
- *** 109,111 ****
- --- 109,143 ----
- back out the above change to xconsole as it plays havoc with
- international kbds where some of the more regular keys are entered by
- alt'ing.
- +
- + -------------------------- Patchlevel 11 ---------------------------------
- +
- + tgetent.c:: ++jrb
- + update default term entry to the one Michal posted.
- +
- + xconsole.c:: ++jrb
- + sync up with console.c: alexander lehmann had a
- + fix there for a bug where console i/o would get stuck when a interrupt
- + was caught and it occured when the input buffer was not empty.
- +
- + tgetent.c:: Michal
- + when I needed it I found that our tgetent routine is buggy since it
- + does not process correctly terminal descriptions with 'tc=...'
- + capabilities. It will also barf on unlikely but legal termcap files
- + where terminal names are split across escaped lines. Use of
- + a static fopenp() does not help either, since that means that
- + forms of PATH you can use there are more restrictive than in other
- + places. Therefore I rewrote that whole file quite a bit.
- + tgetent() now is maybe too permissible but I do not think that
- + it will exclude a valid termcap description.
- +
- + One more modification. When default terminal description is in use
- + then I am filling values for 'co' and 'li' from Line-A variables
- + instead of using a hardwired stuff.
- +
- + xconsole.c:: ++jrb
- + sync up with lib/console.c again. (andreas's change)
- + -- console.c (raw_in): allow typeahead (which is only available at
- + GEMDOS level).
- +
- + -------------------------- Patchlevel 12 ---------------------------------
- *** 1.9 1992/03/06 19:40:24
- --- PatchLev.h 1992/04/19 16:43:24
- ***************
- *** 1,5 ****
- /*
- ! * PathLevel: 11
- *
- * the Patch Level above is to identify the version
- * of the all the files in this directory. given the above
- --- 1,5 ----
- /*
- ! * PathLevel: 12
- *
- * the Patch Level above is to identify the version
- * of the all the files in this directory. given the above
- *** 1.4 1991/05/04 18:38:14
- --- makefile.16 1992/04/19 16:43:29
- ***************
- *** 9,15 ****
-
- MODEL = -I. -mshort
- DEFINES = -DDGK -DGEMDOS
- ! COPTS= -O -fomit-frame-pointer -fcombine-regs -fstrength-reduce \
- -DNDEBUG $(DEFINES) $(XFLAGS)
-
- # normal CFLAGS
- --- 9,15 ----
-
- MODEL = -I. -mshort
- DEFINES = -DDGK -DGEMDOS
- ! COPTS= -O -fomit-frame-pointer -fstrength-reduce \
- -DNDEBUG $(DEFINES) $(XFLAGS)
-
- # normal CFLAGS
- *** 1.4 1991/05/04 18:38:14
- --- makefile.32 1992/04/19 16:43:29
- ***************
- *** 9,15 ****
-
- MODEL = -I.
- DEFINES = -DDGK -DGEMDOS
- ! COPTS= -O -fomit-frame-pointer -fcombine-regs -fstrength-reduce \
- -DNDEBUG $(DEFINES) $(XFLAGS)
-
- # normal CFLAGS
- --- 9,15 ----
-
- MODEL = -I.
- DEFINES = -DDGK -DGEMDOS
- ! COPTS= -O -fomit-frame-pointer -fstrength-reduce \
- -DNDEBUG $(DEFINES) $(XFLAGS)
-
- # normal CFLAGS
- *** 1.5 1991/05/04 18:38:14
- --- tgetent.c 1992/04/19 16:43:33
- ***************
- *** 63,68 ****
- --- 63,73 ----
- *
- * Modification by ERS: if no termcap file can be found, then
- * a default termcap is used (this is for GEMDOS).
- + *
- + * Further mods by MJ: original routines fail to proces valid
- + * termcap files - replaced with new versions.
- + * Atari specific: default termcap used when nothing better is
- + * around reads a number of rows and colums from Line-A variables.
- *
- * RETURNS
- *
- ***************
- *** 86,91 ****
- --- 91,97 ----
- #include <stdio.h>
- #include <string.h>
- #include <termcap.h>
- + #include <ctype.h>
-
- #ifndef _COMPILER_H
- # include <compiler.h>
- ***************
- *** 102,115 ****
-
- # ifdef DGK
- # define DEFAULT_ROOT "termcap" /* name without path component */
- static FILE *fopenp __PROTO((char *name, char *mode, char *pathname));
- # define DEFAULT_FILE "\\etc\\termcap"
- # else
- # define DEFAULT_FILE "/etc/termcap" /* default termcap filename */
- # endif
- ! __EXTERN char *fgetlr __PROTO((char *bp, int bpsize, FILE *fp));
- static FILE *find_file __PROTO((char *));
- static int gotcha __PROTO((char *bp, char *name));
-
- char *_tcpbuf; /* Place to remember buffer pointer */
-
- --- 108,126 ----
-
- # ifdef DGK
- # define DEFAULT_ROOT "termcap" /* name without path component */
- + /**
- static FILE *fopenp __PROTO((char *name, char *mode, char *pathname));
- + **/
- # define DEFAULT_FILE "\\etc\\termcap"
- # else
- # define DEFAULT_FILE "/etc/termcap" /* default termcap filename */
- # endif
- ! /* __EXTERN char *fgetlr __PROTO((char *bp, int bpsize, FILE *fp)); */
- ! static int build_entry __PROTO((char *bp, char *stop, FILE *fp, char *name));
- static FILE *find_file __PROTO((char *));
- + /**
- static int gotcha __PROTO((char *bp, char *name));
- + **/
-
- char *_tcpbuf; /* Place to remember buffer pointer */
-
- ***************
- *** 139,145 ****
- * Return NO_ENTRY status.
- * End if
- * End tgetent
- ! *
- */
-
- int tgetent(bp,name)
- --- 150,167 ----
- * Return NO_ENTRY status.
- * End if
- * End tgetent
- ! *
- ! * Modification by Michal Jagerman (April of 1992):
- ! * The "While records left to process" is too simple minded
- ! * since termcap entry in a buffer can be spliced from
- ! * multiple pieces by using "tc" capability. Therefore
- ! * we delegete the task of termcap buffer filling to
- ! * a specialized internal function 'build_entry()'. This
- ! * function also solves a problem of opening a termcap file
- ! * in a 'wrong' mode by cleaning a termcap buffer from all
- ! * leftovers.
- ! *
- ! *
- */
-
- int tgetent(bp,name)
- ***************
- *** 157,175 ****
- return(NO_FILE);
- }
- } else {
- ! while (fgetlr(bp,BUFSIZE,fp)) {
- ! if (gotcha(bp,name)) {
- ! fclose(fp);
- ! if (bp[(int)strlen(bp)-1] != '\n') {
- ! return(TRUNCATED);
- ! } else {
- ! return(SUCCESS);
- }
- }
- }
- ! return(NO_ENTRY);
- }
- }
-
- /*
- * INTERNAL FUNCTION
- --- 179,371 ----
- return(NO_FILE);
- }
- } else {
- ! *bp++ = ':';
- ! return (build_entry(bp, bp + BUFSIZE - 1, fp, name));
- ! }
- ! }
- !
- ! /*
- ! * INTERNAL FUNCTION
- ! *
- ! * build_entry construct termcap entry in a given buffer
- ! *
- ! * SYNOPSIS
- ! *
- ! * static int build_entry(bp, stop, fp, name)
- ! * char *bp, *stop, *name;
- ! * FILE *fp;
- ! *
- ! * DESCRIPTION
- ! *
- ! * For a given name build in a buffer bp a termcap description
- ! * using a contents of file fp. Continue this until the entry
- ! * is complete or we reached stop. Concatenate entries if
- ! * required by tc capability. White space characters and
- ! * backslashes escaping newlines are not copied into bp.
- ! * Returns SUCCESS if there was no problems, NO_ENTRY if an
- ! * entry with given name was not found and TRUNCATED if we
- ! * run out of a buffer space or continuation entry specified
- ! * with tc was not found
- ! *
- ! * BUGS
- ! *
- ! * Termcap specifications require for tc to be the last capability
- ! * for the given name. This is not enforced but anything which
- ! * follows tc in the same description will be discarded.
- ! * It is not entirely clear what we should return when continuation
- ! * specified with tc failed.
- ! * Other stuff which goes beyond termcap specs can be accepted.
- ! * Terminal names starting with '#' are not accepted.
- ! * Continuation with names over 127 characters long will likely bomb!
- ! *
- ! * AUTHOR
- ! *
- ! * Michal Jaegermann
- ! *
- ! */
- ! static int build_entry(bp, stop, fp, name)
- ! char *bp, *stop, *name;
- ! FILE *fp;
- ! {
- ! int c;
- ! int so_far, skip_all = 0;
- ! char *np;
- ! char nbuf[128];
- ! static int _tgetc __PROTO((FILE *fp));
- !
- ! /* rewind file - we may seek for a continuation entry */
- ! rewind(fp);
- !
- ! /*
- ! * this is FSM - sort of
- ! */
- ! while (EOF != (c = getc(fp))) {
- ! /*
- ! * we are looking at a comment - skip it
- ! */
- ! if ('#' == c) {
- ! do {
- ! if (EOF == (c = getc(fp)))
- ! return NO_ENTRY;
- ! } while ('\n' != c);
- ! }
- ! /*
- ! * empty line or we finished comment traversal;
- ! * a little bit to good - but valid termcap file will be
- ! * stil accepted
- ! */
- ! if (isspace(c))
- ! continue;
- ! /*
- ! * try matching name
- ! */
- ! np = name;
- ! while (*np == c) {
- ! np += 1;
- ! c = _tgetc(fp);
- ! }
- ! /*
- ! * we finished traversing our name - is this really a match ?
- ! */
- ! if (*np == '\0') {
- ! if (c == '|' || c == ':')
- ! break; /* we have a match */
- ! if (c == EOF)
- ! return (TRUNCATED); /* match - but we wanted more */
- ! }
- ! /*
- ! * no match - skip until next name or next entry
- ! * if we are past all possible names here
- ! */
- ! skip_all = 0;
- ! while ('\n' != c) {
- ! if (':' == c)
- ! skip_all = 1; /* we are past all valid names for this entry */
- ! if ('|' == c && 0 == skip_all)
- ! break;
- ! c = _tgetc(fp);
- ! }
- ! }
- ! if (EOF == c)
- ! return (NO_ENTRY);
- ! while (':' != c) /* skip the remainig variants of terminal names */
- ! c = _tgetc(fp); /* we do not want any mixups later */
- !
- ! /*
- ! * at last we got it - copy terminal description into bp
- ! */
- ! so_far = 0; /* rough indicator how far we are into a capability */
- ! while ('\n' != (c = _tgetc(fp))) {
- ! if (0 == so_far && !isalpha(c))
- ! continue; /* do not bother with all kind of spurious stuff */
- ! so_far++;
- ! if (1 == so_far && 't' == c ) {
- ! /* a special case - maybe we have "tc=" string? */
- ! if ((bp + 3) > stop) {
- ! ungetc(c, fp);
- ! continue;
- ! /* cheating with so_far, but we want to skip this case! */
- ! }
- ! *bp++ = c;
- ! c = _tgetc(fp);
- ! if ('c' == c) {
- ! *bp++ = c;
- ! c = _tgetc(fp);
- ! if ('=' == c) {
- ! /* we will continue with a name which follows */
- ! bp -= 2;
- ! /* copy new name to nbuf */
- ! np = nbuf;
- ! while (':' != (c = _tgetc(fp))) {
- ! if ('\n' == c || EOF == c)
- ! break;
- ! *np++ = c;
- ! }
- ! *np = '\0';
- ! return (SUCCESS == build_entry(bp, stop, fp, nbuf) ?
- ! SUCCESS : TRUNCATED);
- }
- }
- + } /* end of 'tc=' check */
- + if (':' == c) /* literal colon cannot occur in capabilities strings -
- + * one has to use '\072' instead */
- + so_far = 0;
- + *bp++ = c;
- + if (bp >= stop)
- + return(TRUNCATED);
- + }
- + if (bp < stop)
- + *bp = '\0';
- + return(SUCCESS);
- + }
- +
- + /*
- + * Auxilary function to read a character from a text file
- + * with skipping escaped line terminators; any escaped
- + * '\n' will be replaced by a character which follows.
- + * After escape any number of ^M's will vanish,
- + * i.e a string of three characters '\\', 0x0d, 'a' will read
- + * as a string of two characters '\\', 'a' and so on...
- + * We do not tolerate such garbage in text files. :-)
- + */
- + static int _tgetc(fp)
- + FILE *fp;
- + {
- + int c;
- +
- + if ('\\' == (c = getc(fp))) {
- + while ('\r' == (c = getc(fp)))
- + ; /* Messy stuff - go away */
- + if (c != '\n') {
- + ungetc(c, fp);
- + return ('\\');
- }
- ! c = getc(fp);
- }
- + return(c);
- }
- +
- +
-
- /*
- * INTERNAL FUNCTION
- ***************
- *** 234,244 ****
- *
- */
-
- ! static char term_default[] = "df|default|Atari default\
- ! :al=\\EL:am:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :co#80:dl=\\EM\
- ! :do=\\EB:eo:ho=\\EH:is=\\Eq\\EE\\Ee\\Ev:it#8:le=^H:li#25:ll=\\EY9!\
- ! :me=\\Eq:mr=\\Ep:nd=\\EC:rc=\\Ek:sc=\\Ej:se=\\Eq:so=\\Ep:ta=^I\
- ! :up=\\EA:ve=\\Ee:vi=\\Ef:";
-
- static FILE *find_file(bp)
- char *bp;
- --- 430,455 ----
- *
- */
-
- ! #ifdef GEMDOS
- ! /*
- ! * we do not really need the following part once the stuff is in
- ! * our termcap buffer
- ! */
- ! /* "df|default|Atari default" */
- ! /*
- ! * this values we will try to fill to fit a given display
- ! */
- ! /* :co#80:li#25:\ */
- !
- ! static char term_default[] = "\
- ! :al=\\EL:am:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :dl=\\EM\
- ! :do=\\EB:eo:ho=\\EH:is=\\Eq\\EE\\Ee\\Ev:it#8:pt:kb=^H:ll=\\EY9!\
- ! :me=\\Eq:mr=\\Ep:le=\\ED:nd=\\EC:rc=\\Ek:sc=\\Ej:se=\\Eq:so=\\Ep:ta=^I\
- ! :up=\\EA:ve=\\Ee:vi=\\Ef:km:bl=^G:cr=^M:ti=\\Ev\\Ee:sr=\\EI:sf=^J";
- !
- ! #include <linea.h>
- ! #include <support.h>
- ! #endif
-
- static FILE *find_file(bp)
- char *bp;
- ***************
- *** 268,278 ****
- return fp;
- else if (fp = fopen(DEFAULT_FILE, "r"))
- return fp;
- else if (fp = fopenp(DEFAULT_ROOT, "r", NULL))
- return fp;
- else {
- # ifdef GEMDOS
- ! strcpy (bp, term_default);
- # endif
- return (FILE *) NULL;
- }
- --- 479,507 ----
- return fp;
- else if (fp = fopen(DEFAULT_FILE, "r"))
- return fp;
- + else if (NULL !=
- + (cp = findfile(DEFAULT_ROOT, getenv("PATH"), (char **)0)) &&
- + (NULL != (fp = fopen(cp,"r"))))
- + return fp;
- +
- + /** this replaced by the above **
- else if (fp = fopenp(DEFAULT_ROOT, "r", NULL))
- return fp;
- + **/
- else {
- # ifdef GEMDOS
- ! /*
- ! * if we do not have any better information, then
- ! * we will try to glimpse screen sizes from Line-A variables
- ! */
- ! linea0();
- ! strcpy (bp, ":co#");
- ! (void) _ultoa((unsigned long) (V_CEL_MX + 1),
- ! bp + sizeof(":co#") - 1, 10);
- ! strcat (bp, ":li#");
- ! (void) _ultoa((unsigned long) (V_CEL_MY + 1),
- ! bp + strlen(bp), 10);
- ! strcat (bp, term_default);
- # endif
- return (FILE *) NULL;
- }
- ***************
- *** 280,285 ****
- --- 509,515 ----
- return(fopen(DEFAULT_FILE,"r"));
- # endif
- }
- + #if 0 /* this is not used anymore */
-
- /*
- * INTERNAL FUNCTION
- ***************
- *** 360,365 ****
- --- 590,598 ----
- * argument which can be NULL. Otherwise this argument gets filled
- * in the full path to the file. Returns as does fopen().
- */
- +
- + /* On Atari ST use library routine findfile() instead */
- +
- static FILE *
- fopenp(name, mode, pathname)
- char *name, *mode, *pathname;
- ***************
- *** 393,395 ****
- --- 626,629 ----
- return NULL;
- }
- #endif
- + #endif /* 0 */
- *** 1.7 1992/03/06 19:40:24
- --- xconsole.c 1992/04/19 16:43:35
- ***************
- *** 71,85 ****
- } k_buf;
-
- static k_buf in_buf[NUMDEV];
- - #define IN_BUF(dev) (&in_buf[(dev) > 2 ? _console_dev : (dev)])
-
- /*
- * what handle means:: 0-2: BIOS handle, 3: stdout, 4: stderr
- */
-
- static short
- LOOKUP(handle)
- short handle;
- {
- switch(handle) {
- case -3:
- --- 71,100 ----
- } k_buf;
-
- static k_buf in_buf[NUMDEV];
-
- + #define in_dev(dev) ((dev)>2 ? _console_dev : (dev))
- +
- + #define IN_BUF(dev) (&in_buf[in_dev(dev)])
- +
- +
- /*
- * what handle means:: 0-2: BIOS handle, 3: stdout, 4: stderr
- */
- + static short LOOKUP __PROTO((short handle));
- + static long raw_in __PROTO((int dev));
- + static long raw_instat __PROTO((int dev));
- + void flush_key_buff __PROTO((int dev));
- + #if 0
- + static void raw_out __PROTO((int dev, int c));
- + #endif
-
- static short
- + #ifdef __STDC__
- + LOOKUP(short handle)
- + #else
- LOOKUP(handle)
- short handle;
- + #endif
- {
- switch(handle) {
- case -3:
- ***************
- *** 106,117 ****
- raw_in(dev)
- int dev;
- {
- ! if (dev < 3)
- ! return Bconin(dev);
- ! else if (dev == 3)
- ! return Crawcin();
- ! else
- ! return Cauxin();
- }
-
- #if 0
- --- 121,132 ----
- raw_in(dev)
- int dev;
- {
- ! if (dev < 3)
- ! return Bconin (dev);
- ! else if (dev == 3)
- ! return Crawcin ();
- ! else
- ! return Cauxin ();
- }
-
- #if 0
- ***************
- *** 132,143 ****
- raw_instat(dev)
- int dev;
- {
- ! if (dev < 3)
- ! return Bconstat(dev);
- ! else if (dev == 3)
- ! return Cconis();
- ! else
- ! return Cauxis();
- }
-
- /*
- --- 147,153 ----
- raw_instat(dev)
- int dev;
- {
- ! return Bconstat(in_dev(dev));
- }
-
- /*
- ***************
- *** 211,257 ****
- int handle;
- int n;
- {
- ! long c;
- ! short i, j, waiting = 0;
- ! unsigned char ch;
- ! k_buf *p;
- short dev;
-
- dev = LOOKUP(handle);
- - p = IN_BUF(dev);
-
- ! while (__check_signals && (raw_instat(dev) || waiting)) {
- ! c = raw_in(dev);
- ! if (!(__ttymode & RAW)) {
- ! ch = c & 0xff;
- ! if (ch == ('S'-'@')) {
- ! waiting = 1;
- ! }
- ! else if (ch == ('Q'-'@')) {
- ! waiting = 0;
- ! }
- ! else if (ch == __tchars[TC_INTRC]) {
- ! p->head = p->tail;
- ! raise(SIGINT);
- ! }
- ! else if (ch == __tchars[TC_QUITC]) {
- ! p->head = p->tail;
- ! raise(SIGQUIT);
- ! }
- ! else if (!waiting) {
- ! i = p->head;
- ! j = i + 1;
- ! if (j >= KBUFSIZ) j = 0;
- ! if (j != p->tail) {
- ! p->buffer[i] = c;
- ! p->head = j;
- ! }
- ! }
- ! }
- ! }
- ! #if 0
- ! raw_out(dev, n);
- ! #endif
- ch = n;
- (void)Fwrite(handle, 1L, &ch);
- }
- --- 221,234 ----
- int handle;
- int n;
- {
- ! char ch;
- short dev;
-
- dev = LOOKUP(handle);
-
- ! if (__check_signals)
- ! flush_key_buff(dev);
- ! /* raw_out(dev, n); */
- ch = n;
- (void)Fwrite(handle, 1L, &ch);
- }
-